package com.taotao.rest.controller;


import java.util.List;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fasterxml.jackson.databind.util.JSONPObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.taotao.pojo.TbOrder;
import com.taotao.rest.service.OrderService;


@Controller
public class OrderController {
	@Autowired
	private OrderService OrderService;
	
	@ResponseBody
	@RequestMapping("/order2")
	public JSONPObject  myOrdersWithJson2(@RequestParam(value="pn",defaultValue="1")Integer pn,
			@RequestParam(required=false,value="callbackparam")String  callbackparam) {
		// 引入PageHelper分页插件
				// 在查询之前只需要调用，传入页码，以及每页的大小
				PageHelper.startPage(pn, 5);
				List<TbOrder> orders=OrderService.getAllOrder();
				// 使用pageInfo包装查询后的结果，只需要将pageInfo交给页面就行了。
				// 封装了详细的分页信息,包括有我们查询出来的数据，传入连续显示的页数
				PageInfo page = new PageInfo(orders, 5);
				//String callback = request.getParameter("callback"); 
				//return Msg.success().add("pageInfo", page);
				
				 JSONPObject jsonPobject=new JSONPObject(callbackparam, page);  //函数名称
				return jsonPobject;  
	}
}